/**
 * 路由配置文件
 * 使用 React.lazy 实现组件懒加载，优化应用性能
 * 定义应用的所有路由路径和对应的组件
 */

import { lazy } from "react";

/**
 * 使用 React.lazy 懒加载组件
 * 好处：
 * 1. 减小初始包体积
 * 2. 按需加载组件
 * 3. 提高首屏加载速度
 */

// 首页组件
const Home = lazy(() => import('../views/Home/Index'));
// 邮箱页面组件
const Email = lazy(() => import('../views/Email/Index'));
// 搜索页面组件
const Search = lazy(() => import('../views/Search/Index'));
// 用户页面组件
const User = lazy(() => import('../views/User/Index'));
// 病友圈列表页面组件
const Moments = lazy(() => import('../views/Moments/Index'));
// 病友圈详情页面组件
const MomentsDetail = lazy(() => import('../views/Moments/Detail'));
// 登录页面组件
const Login = lazy(() => import('../views/Login/Index'));
// 患者登录页面组件
const PatientLogin = lazy(() => import('../views/Login/Index2'));
// 健康商店页面组件
const Store = lazy(() => import('../views/Store/Index'));
// 问诊聊天页面组件
const Inquiry = lazy(() => import('../views/Inquiry/Chat'));
// 医生问诊聊天页面组件
const DoctorChat = lazy(() => import('../views/Inquiry/DoctorChat'));
// 医生列表页面组件
const Doctor = lazy(() => import('../views/Doctor/List'));
// 医生详情页面组件
const DoctorDetail = lazy(() => import('../views/Doctor/Detail'));
// 医生评价页面组件
const DoctorEvaluate = lazy(() => import('../views/Doctor/Evaluate'));
// 问诊医生列表页面组件
const DoctorList = lazy(() => import('../views/Inquiry/DoctorList'));
// 问诊历史页面组件
const InquiryHistory = lazy(() => import('../views/Inquiry/History'));
// // 问诊记录详情页面组件
// const InquiryRecord = lazy(() => import('../views/Inquiry/Record'));
// // 问诊评价页面组件
// const InquiryEvaluate = lazy(() => import('../views/Inquiry/Evaluate'));

/**
 * 路由配置数组
 * 每个路由对象包含：
 * - path: 路由路径
 * - element: 对应的组件
 * 
 * 特殊路由说明：
 * - '/moments/detail/:sickCircleId': 动态路由，:sickCircleId 为参数
 * - '/': 根路由，重定向到首页
 */
const router = [
  {
    path: '/',
    element: <Home />,
  }, {
    path: "/home",
    element: <Home />,
  }, {
    path: '/search',
    element: <Search />,
  }, {
    path: '/moments',
    element: <Moments />,
  }, {
    path: '/moments/detail/:sickCircleId',
    element: <MomentsDetail />,
  }, {
    path: '/email',
    element: <Email />,
  }, {
    path: '/user',
    element: <User />
  }, {
    path: '/login',
    element: <Login />
  }, {
    path: '/patient-login',
    element: <PatientLogin />
  }, {
    path: '/store',
    element: <Store />
  }, {
    path: '/inquiry',
    element: <Inquiry />
  }, {
    path: '/inquiry/new',
    element: <Inquiry />
  }, {
    path: '/inquiry/chat/:doctorId',
    element: <Inquiry />
  }, {
    path: '/doctor/inquiry/chat/:id',
    element: <DoctorChat />
  }, {
    path: '/inquiry/history',
    element: <InquiryHistory />
  }, {
    path: '/doctor',
    element: <Doctor />
  }, {
    path: '/doctor/detail/:doctorId',
    element: <DoctorDetail />
  }, {
    path: '/doctor/evaluate/:doctorId',
    element: <DoctorEvaluate />
  }, {
    path: '/doctor/list',
    element: <DoctorList />
  }
];

export default router;